<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script src="./axios.min.js"></script>
<script>
  // 1. 对axios做封装
  // 分身
  let instance = axios.create({
    baseURL:`http://localhost:3000`, //集中配置基础URL
    headers:{   //集中配置请求头
      'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0aW1lIjoxNzM5MzQyMzY1MjMyLCJleHBpcmUiOjcyMDAwMDAsImlhdCI6MTczOTM0MjM2NX0.e25oEW0b8wxmDfMW7dKOBocIRSso27xqpHWpbogohjU'
    }
  })

  // 2. 使用封装后的方法进行网络请求
  instance.get('/fanji').then(res=>{
    console.log(res);
    alert(res.data.msg)   //在请求结束后需要为用户做明确的提示
  })

  instance.post('/fanji',{list:[]}).then(res=>{
    console.log(res);
    alert(res.data.msg)
  })
  

</script>
</html>